package annotation.getters;

import org.openqa.selenium.WebElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import annotation.Args;
import annotation.IPropertityGetter;
import annotation.source.AttributeSelector;
import tools.AnnotationUtil;

/**
 *
 * @author: Wang Yuxin
 * @email: 1325943548@qq.com
 * @create: 2022-10-04 21:18
 * @see AttributeSelector
 */
public class AttributePropertityGetter implements IPropertityGetter<String, WebElement> {
    static Logger logger = LoggerFactory.getLogger(AttributePropertityGetter.class);
    @Override
    public String getPropertity(WebElement webElement, Object pageObject, Args addtionArgs) {
        String attr = AnnotationUtil.<String>getArgValueOptional(addtionArgs,"attr")
                .orElse("value");
        return webElement.getAttribute(attr);
    }
}
